package com.keba.lamp.complaint.service.impl;

import com.aliyun.core.utils.StringUtils;
import com.google.common.collect.Lists;
import com.keba.basic.base.service.impl.SuperServiceImpl;
import com.keba.basic.database.mybatis.conditions.Wraps;
import com.keba.lamp.complaint.entity.CourtArea;
import com.keba.lamp.complaint.manager.CourtAreaManager;
import com.keba.lamp.complaint.service.CourtAreaService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 业务实现类
 * 法院区域关系表
 * </p>
 *
 * @author twg
 * @date 2025-07-09 15:51:09
 * @create [2025-07-09 15:51:09] [twg] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Service
@Transactional(readOnly = true)
public class CourtAreaServiceImpl extends SuperServiceImpl<CourtAreaManager, Long, CourtArea> implements CourtAreaService {

    @Override
    public CourtArea getByCourtName(String courtName) {
        if (StringUtils.isBlank(courtName)) {
            return null;
        }
        return getSuperManager().getOne(Wraps.<CourtArea>lbQ().eq(CourtArea::getCourtName, courtName));
    }

    @Override
    public List<CourtArea> queryByCourtName(String courtName) {
        if (StringUtils.isBlank(courtName)) {
            return Lists.newArrayList();
        }
        return getSuperManager().list(Wraps.<CourtArea>lbQ().like(CourtArea::getCourtName, courtName));
    }


    @Override
    public List<CourtArea> queryByAreaId(Long areaId) {
        if (Objects.isNull(areaId)) {
            return Lists.newArrayList();
        }
        return getSuperManager().list(Wraps.<CourtArea>lbQ().eq(CourtArea::getAreaId, areaId));
    }
}


